<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2024092802</title>
    <style>
        .container {
            position: relative;
            height: 100vh;
        }
        
        .centered-div {
            height: 600px;
            width: 900px;
            text-align: center;
            background: #eee;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
        
        img {
            height: 96%;
            margin: 2%;
            border-radius: 6%;
        }
        
        .center1 {
            width: 96%;
            position: absolute;
            top: 50%;
            transform: translate(0, -50%);
        }
        
        button {
            border-radius: 100%;
            background-color: transparent;
            position: absolute;
            transform: translate(0, -50%);
        }
        
        li {
            width: 10px;
            height: 10px;
            float: left;
            margin: 3.25%;
            background: #fff;
            list-style: none;
            border-radius: 100%;
        }
        
        .div3 {
            width: 98%;
            position: absolute;
            bottom: 1%;
            text-align: right;
        }
        
        span {
            color: #fff;
            font-size: 20px;
            font-weight: bold;
        }
    </style>
</head>

<body class="container">
    <div class="centered-div">
        <img class="" id="img" src="../img/img/1.jpg" alt="">
        <div class="center1">
            <button style="left: 2%" onclick="lr('l')"><span><</span></button>
            <button style="right: -2%;" onclick="lr('r')"><span>></span></button>
        </div>
        <div class="div3">
            <ul>
            </ul>
        </div>
    </div>
    <script>
        let counter = 0;
        let n = 13;
        let img = document.getElementById('img');
        let ulo = document.getElementsByTagName('ul')[0];
        let lis = [];
        for (let i = 0; i < n; i++) {
            let li = document.createElement('li');
            li.style.backgroundColor = i != 0 ? '#fff' : "blue";
            li.onmouseover = function() {
                lis[counter % n].style.backgroundColor = '#fff';
                counter = i;
                img.src = "../img/img/" + (counter % n + 1) + ".jpg";
                img.onerror = function() {
                    img.src = "../img/img/" + (counter % n + 1) + ".png";
                }
                li.style.backgroundColor = 'blue';
            }
            lis.push(li);
            ulo.appendChild(li);
        }
        setInterval(function() {
            lis[counter % n].style.backgroundColor = '#fff';
            counter++;
            img.src = "../img/img/" + (counter % n + 1) + ".jpg";
            img.onerror = function() {
                img.src = "../img/img/" + (counter % n + 1) + ".png";
            }
            lis[counter % n].style.backgroundColor = 'blue';
        }, 3000);

        function lr(flag) {
            lis[counter % n].style.backgroundColor = '#fff';
            if (flag === 'l') counter += lis.length - 1;
            else counter++;
            img.src = "../img/img/" + (counter % n + 1) + ".jpg";
            img.onerror = function() {
                img.src = "../img/img/" + (counter % n + 1) + ".png";
            }
            lis[counter % n].style.backgroundColor = 'blue';
        }
    </script>
</body>

</html>